package com.example.login;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

    private  EditText ed1 = null;
    private  EditText ed2 = null;
    private  String name  = "1001";
    private  String password = "1001";


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        ed1 =  findViewById(R.id.ed_1);
        ed2 =  findViewById(R.id.ed_2);

    }




    public void anxia(View v)
    {
        String n = ed1.getText().toString();
        String p = ed2.getText().toString();


        if(TextUtils.isEmpty(n))//判断内容是否为空
        {
            Toast.makeText(this, "请输入正确的账号", Toast.LENGTH_SHORT).show();

            return;
        }
        if(TextUtils.isEmpty(p))
        {
            Toast.makeText(this, "请输入正确的密码", Toast.LENGTH_SHORT).show();

            return;
        }

        if(n.equals(name) && p.equals(password))//判断获取的是否和设置的一样
        {
            Intent intent = new Intent(this,MainActivity2.class);

            intent.putExtra("Data",n);

            startActivity(intent);
            //2.uri跳转
            //        Uri uri= Uri.parse("tel:10086");
            //        Intent intent = new Intent(Intent.ACTION_DIAL,uri);
            //
            //        startActivity(intent);

            return;
        }

        Toast.makeText(this, "账号或密码输入有误", Toast.LENGTH_SHORT).show();









    }
}